<?php
/**
 * 活动申请
 * @author Administrator
 *
 */
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ActivityApply extends Model
{
    //
	protected $table = 'activity_apply';

    protected function getDateFormat()
    {
        return 'U';
    }

    public function User(){
		return $this->belongsTo('App\Models\User','uid','uid');
	}

    public function Activity(){
        return $this->belongsTo('App\Models\Activity','activity_id','id');
    }

    public function Maker(){
        return $this->belongsTo('App\Models\Maker','maker_id','id');
    }

    public function Zone(){
        return $this->belongsTo('App\Models\Zone','join_zone_id','id');
    }

	static function getApplyId($uid){

		return  self::where('uid',$uid)->lists('activity_id')->toArray();
	}

	//获取报名活动的用户的信息
	static function getApplyUser($activity_id){
		$users = self::with('User')->where('activity_id',$activity_id)->where('status',1)->get();
		
		foreach ($users as $key => $val) {
			$result[$key]['id'] = $val->id;
			$result[$key]['image'] = $val->User->avatar;
			$result[$key]['name'] = $val->nickname;
		}
		if(isset($result))
			return $result;
		else
			return false;
	}
}
